﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Persistente.Auxiliar
{
    public class PStatus
    {
        private DB_FINALCOUNTDOWN _db;
        private SqlConnection _conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_FINALCOUNTDOWN_SQL"].ConnectionString);

        public List<tb_status> pegarTodosStatus()
        {
            var listStatus = new List<tb_status>();
            try
            {
                _db = new DB_FINALCOUNTDOWN();
                listStatus = _db.tb_status.ToList();
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                _db.Connection.Close();
            }
            return listStatus;

        }

        public tb_status pegarStatusPorId(int idStatus)
        {
            try
            {
                _db = new DB_FINALCOUNTDOWN();
                return _db.tb_status.Where(q => q.id_status == idStatus).FirstOrDefault();
            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                _db.Connection.Close();
            }
        }
    }
}
